﻿@model ViewModels.User._InviteCodeModel
@{
	var request = ViewContext.HttpContext.Request;
	string url = $"{request.Scheme}://{request.Host}/User/Register?ic={Model.UserId}-{Model.InviteCode}";
    IList<ViewModels.Components.NavigatorModel> Invitees = Model.Invitees;
}

<p>你的邀请码是：</p>
<h3>@Model.UserId-@Model.InviteCode</h3>

<p>
	告诉给你的朋友，或者直接给ta链接：
</p>
<p class="text-primary">
	<a id="target">@url</a>
	<button zyf-inviteCode-clipboard class="btn btn-success btn-sm" data-clipboard-target="#target"> <i class="fa fa-link"></i> 复制</button>
</p>
<p>
    @if (Model.Invitees.Count > 0)
    {
        <span>
            你已经邀请了 <span class="text-success">@Model.Invitees.Count </span> 人（挣得1帮帮币）：
        </span>
        <br />
        for (int i = 0; i < Invitees.Count; i++)
        {
            <span>
                @(i + 1)）<a class="mr-2" href="/User/HomePage/@Invitees[i].UserId">@Invitees[i].NickName</a>
            </span>
        }
    }
    else
    {
        <span>但还没有邀请任何人呢！¯\_(ツ)_/¯</span>
    }
</p>
<p>继续加油哟！</p>

<script src="/lib/clipboard.min.js"></script>
<script>
    new ClipboardJS('[zyf-inviteCode-clipboard]');
    function makeInviteCode() {
        $.ajax({
            url: "/User/_MakeInviteCode",
            success: function (data) {
                location = location;
            },
            error: JqueryAjaxError
        })
    }
</script>